import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class CustomPaintPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _CustomPaintPage();
  }
}

class _CustomPaintPage extends State<CustomPaintPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomPaint(
        painter: Painter(),
      ),
    );
  }
}

class Painter extends CustomPainter {
  var _paint = Paint()
    ..color = Colors.red
    ..isAntiAlias = true
    ..strokeCap = StrokeCap.round
    ..style = PaintingStyle.fill
    ..strokeWidth = 6.0;

  @override
  void paint(Canvas canvas, Size size) {
    var width = 300;
    var height = 400;
    Path path = Path();
    path.moveTo(width / 2, height / 4);
    path.cubicTo((width * 6) / 7, height / 9, (width * 12) / 13,
        (height * 2) / 5, width / 2, (height * 7) / 12);
    canvas.drawPath(path, _paint);

    Path path2 = Path();
    path2.moveTo(width / 2, height / 4);
    path2.cubicTo(width / 7, height / 9, width / 13, (height * 2) / 5,
        width / 2, (height * 7) / 12);
    canvas.drawPath(path2, _paint);

    canvas.drawPoints(PointMode.points, [Offset(width / 2, height / 4)], _paint);
    canvas.drawPoints(PointMode.points, [Offset((width * 6) / 7, height / 9)], _paint);
    canvas.drawPoints(PointMode.points, [Offset((width * 12) / 13,(height * 2) / 5)], _paint);
    canvas.drawPoints(PointMode.points, [Offset(width / 2, (height * 7) / 12)], _paint);

    canvas.drawPoints(PointMode.points, [Offset(width / 7, height / 9)], _paint);
    canvas.drawPoints(PointMode.points, [Offset(width / 13, (height * 2) / 5)], _paint);
    canvas.drawPoints(PointMode.points, [Offset(width / 2, (height * 7) / 12)], _paint);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) {
    return true;
  }
}
